/*
 * This source code is part of TWaver 4.0
 *
 * Serva Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * Copyright 2002 - 2011 Serva Software. All rights reserved.
 */

package demo.network.topo.titlegroup;

import java.awt.BorderLayout;
import java.awt.Color;

import twaver.AlarmSeverity;
import twaver.Link;
import twaver.Node;
import twaver.TWaverConst;
import twaver.network.TNetwork;
import demo.DemoPane;

public class TitleGroupDemo extends DemoPane {

    public TitleGroupDemo() {
        TNetwork network = new TNetwork();
        network.getDataBox().setAlarmPropagator(null);
        this.add(network, BorderLayout.CENTER);
        TitleGroup group = new TitleGroup();
        group.setLocation(300, 200);
        network.getDataBox().addElement(group);

        Node node1 = new Node();
        node1.setLocation(100, 100);
        node1.setParent(group);
        node1.setName("Node1");
        network.getDataBox().addElement(node1);

        Node node2 = new Node();
        node2.setLocation(350, 200);
        node2.setParent(group);
        node2.setName("Node2");
        node2.getAlarmState().addNewAlarm(AlarmSeverity.CRITICAL);
        network.getDataBox().addElement(node2);

        Link link = new Link(node1, node2);
        link.setLinkType(TWaverConst.LINK_TYPE_FLEXIONAL);
        link.putLinkWidth(5);
        link.putLink3D(true);
        link.putLinkAntialias(true);
        link.putLinkColor(Color.cyan.darker());
        network.getDataBox().addElement(link);

        group.setExpand(true);
        group.setName("THIS GROUP HAS A VERY VERY VERY LONG TITLE, WE CAN HANDLE IT.");

        Node node3 = new Node();
        node3.setLocation(550, 150);
        node3.setName("Node3");
        node3.getAlarmState().addNewAlarm(AlarmSeverity.MAJOR);
        network.getDataBox().addElement(node3);

        link = new Link(node2, node3);
        link.setLinkType(TWaverConst.LINK_TYPE_FLEXIONAL);
        link.putLinkWidth(5);
        link.putLink3D(true);
        link.putLinkAntialias(true);
        link.putLinkColor(Color.orange.darker());
        network.getDataBox().addElement(link);
    }
}